// 1. 从依赖包中导入路由函数 createRouter 和 createWebHistory。
import { createRouter, createWebHistory } from "vue-router";

// 2. 从其他文件导入路由组件。


// 3. 定义一些路由。每个路由都需要映射到一个组件。
// @ts-ignore
const routes = [
    {
        path: "/",
        redirect: "/user/delivery1",
    },

    {
        path: "/login",
        name: "Login",
        component: () => import("./pages/Login.vue"),
    },
    {
        path: "/multilogin",
        name: "multilogin",
        component: () => import("./pages/multilogin/Login.vue"),
    },
    {
        path: "/Home",
        name: "Home",
        component: () => import("./pages/user/Home.vue"),
        children: [
            {
                path: "order",
                name: "order",
                component: () => import("./pages/user/order.vue"),
            },
        ]
    },
    {
        path: "/user",
        name: "AdminIndex",
        component: () => import("./Pages/user/AdminIndex.vue"),
        children: [
            {
                path: "shop",
                name: "Delivery",
                component: () => import("./pages/user/delivery/Delivery.vue"),
            },
            {
                path: "delivery1",
                name: "Delivery1",
                component: () => import("./pages/user/delivery/Delivery1.vue"),
            },
            {
                path: "xd",
                name: "xd",
                component: () => import("./pages/user/delivery/xd.vue"),
            },
            {
                path: "address",
                name: "Address",
                component: () => import("./pages/user/my/Address.vue"),
            },
            {
                path: "HistoricalOrders",
                name: "HistoricalOrders",
                component: () => import("./pages/user/order/HistoricalOrders.vue"),
            },
            {
                path: "InfoEditing",
                name: "InfoEditing",
                component: () => import("./pages/user/my/InfoEditing.vue"),
            }

        ]
    },

    {
        path: "/shop",
        name: "ShopAdminIndex",
        component: () => import("./pages/shop/ShopAdminIndex.vue"),
        children: [
            {
                path: "dishes",
                name: "dishesIndexPage",
                component: () => import("./Pages/shop/dishesPages/IndexPage.vue"),
            },
            {
                path: "ordering",
                component: () => import("./Pages/shop/dingDanPages/OrderProcessingPage.vue"),
            },
            {
                path: "completed",
                component: () => import("./Pages/shop/dingDanPages/OrderCompletedPage.vue"),
            },
            {
                path: "set",
                name: "update",
                component: () => import("./Pages/shop/settingPages/UpdatePage.vue"),
            },
             {
                path: "income",
                name: "incomeChart",
                component: () => import("./Pages/shop/income/IncomeChart.vue"),
             },
            {
                path: "incomeDay",
                name: "incomeDay",
                component: () => import("./Pages/shop/income/DailyIncomeChart.vue"),
            },
        ]
    },
    //
    {
        path: "/rider",
        name: "riderAdminIndex",
        component: () => import("./pages/rider/AdminIndex.vue"),
        children: [
            /*{
                path: "data",
                name: "DataAnalysisIndex",
                component: () => import("./pages/rider/data/DataAnalysisIndex.vue"),
            },*/
            {
                path: "profile",
                name: "ProfilePage",
                component: () => import("./pages/rider/Profile.vue"),
            },
            {
                path: "ordering",
                name: "orderProcessing",
                component: () => import("./Pages/rider/OrderProcessingPage.vue"),
            },
            {
                path: "completed",
                name: "orderCompleted",
                component: () => import("./Pages/rider/OrderCompletedPage.vue"),
            },
            {
                path: "login",
                name: "RiderLogin",
                component: () => import("./pages/rider/LoginPage.vue"),
            },
            {
                path: "register",
                name: "RiderRegister",
                component: () => import("./pages/rider/RegisterPage.vue"),
            },

        ]

    },

    {
        path: "/admin",
        name: "ManagerAdminIndex",
        component: () => import("./pages/admin/ManagerAdminIndex.vue"),
        children: [
            {
                path: "order",
                name: "orderIndexPage",
                component: () => import("./pages/admin/order/IndexPage.vue"),
            },
            {
                path: "shop",
                name: "shopIndexPage",
                component: () => import("./pages/admin/shop/IndexPage.vue"),
            },
            {
                path: "data",
                name: "dataIndexPage",
                component: () => import("./pages/admin/statistics/IndexPage.vue"),
            },
            {
                path: "system",
                name: "systemIndexPage",
                component: () => import("./pages/admin/system/IndexPage.vue"),
            },
            {
                path: "user",
                name: "userIndexPage",
                component: () => import("./pages/admin/user/IndexPage.vue"),
            },
            {
                path: "rider",
                name: "riderIndexPage",
                component: () => import("./pages/admin/rider/IndexPage.vue"),
            },

        ]

    },




    {
        path: '/404',
        name: '404',
        component: () => import('./Pages/404.vue'),
    },
    {
        path: '/:pathMatch(.*)',
        redirect:"/404",
    },
];

// 4. 使用 createRouter 方法创建一个路由实例 router。
const router = createRouter({
    history: createWebHistory(),
    routes, // `routes: routes` 的缩写
});

// 5. 导出路由对象。
export default router;